#include <stdio.h>

/* Factorize n = p[0]^k[0] * ... * p[m-1]^k[m-1]. Returns m. */
int factorize(int n, int p[], int k[])
{
    int m = 0;
    int pp;

    if (n <= 1)
        return 0;

    if (n % 2 == 0)
    {
        p[m] = 2;
        k[m] = 0;
        while (n % 2 == 0)
        {
            ++k[m];
            n /= 2;
        }
        m++;
    }

    for (pp = 3; pp * pp <= n; pp += 2)
    {
        if (n % pp == 0)
        {
            p[m] = pp;
            k[m] = 0;
            while (n % pp == 0)
            {
                ++k[m];
                n /= pp;
            }
            m++;
        }
    }
    if (n > 1)
    {
        p[m] = n;
        k[m] = 1;
        m++;
    }
    return m;
}

#define abs(x) (((x) < 0)? -(x) : (x))

int main()
{
    int n1, n2, t;
    for (t = 1; scanf("%d %d", &n1, &n2) == 2 && !(n1 == 0 && n2 == 0); t++)
    {
        int p1[32], k1[32], p2[32], k2[32];
        int m1 = factorize(n1, p1, k1);
        int m2 = factorize(n2, p2, k2);

        int dim = 0, distance = 0;
        int i1, i2;
        for (i1 = i2 = 0; i1 < m1 && i2 < m2; )
        {
            if (p1[i1] < p2[i2])
            {
                ++dim;
                distance += k1[i1];
                ++i1;
            }
            else if (p1[i1] > p2[i2])
            {
                ++dim;
                distance += k2[i2];
                ++i2;
            }
            else 
            {
                ++dim;
                distance += abs(k1[i1] - k2[i2]);
                ++i1;
                ++i2;
            }
        }
        for (; i1 < m1; i1++)
        {
            ++dim;
            distance += k1[i1];
        }
        for (; i2 < m2; i2++)
        {
            ++dim;
            distance += k2[i2];
        }

        printf("%d. %d:%d\n", t, dim, distance);
    }
    return 0;
}
